import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';

//#region 文章类型
export enum ArticleTypeEnum {
  Carousel = 0,
  News,
}

export class ArticleTypeEntity {
  Type: ArticleTypeEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(articleType: ArticleTypeEnum, color?: PresetColorEnum | string) {
    this.Type = articleType;
    this.Color = color;
    switch (articleType) {
      case ArticleTypeEnum.Carousel:
        this.Display = '轮播';
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
      case ArticleTypeEnum.News:
        this.Display = '资讯';
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
    }
  }
}

export function getArticleTypeEnumSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const typeEntities: ArticleTypeEntity[] = [
    new ArticleTypeEntity(ArticleTypeEnum.Carousel),
    new ArticleTypeEntity(ArticleTypeEnum.News),
  ];
  typeEntities.forEach((item) => {
    enumSchema.push({
      key: item.Type as number,
      label: item.Display,
      value: item.Type as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
